export function calculateDistance(latitude: number,longitude: number,latitude2: number,longitude2: number) : number {
    const R = 6371;   //地球半径
    //latitude 纬度  
    //longitude 经度
    const dLat = toRadians(latitude - latitude2);
    const dLon = toRadians(longitude - longitude2);
    const a =
        Math.sin(dLat / 2) * Math.sin(dLat / 2) +
        Math.cos(toRadians(latitude)) *
        Math.cos(toRadians(latitude2)) *
        Math.sin(dLon / 2) *
        Math.sin(dLon / 2);
    const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    return (R * c).toFixed(3);
}

function toRadians(degrees: number) : number {
    return degrees * (Math.PI / 180);
}